package com.example.dingtalk.service;

import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponseBody;
import com.aliyun.dingtalkworkflow_1_0.models.ListProcessInstanceIdsResponseBody;
import com.dingtalk.api.response.OapiProcessWorkrecordTaskQueryResponse;
import com.taobao.api.ApiException;

import java.io.IOException;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;

/**
 * @author Administrator
 */
public interface OaService {


    /**
     * 获取实例详情
     * @param processInstanceId
     * @return
     * @throws Exception
     */
    GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResult getProcessInstance(String processInstanceId) throws Exception;

    /**
     * 获取所有待办审批流ID列表
     * @param startTime
     * @param processCode
     * @param nextToken
     * @param maxResults
     * @param statuses
     * @return
     * @throws Exception
     */
    ListProcessInstanceIdsResponseBody.ListProcessInstanceIdsResponseBodyResult getProcessListByPage(Long startTime, String processCode, Long nextToken, Long maxResults, String statuses) throws Exception;

    /**
     * 处理已完成审批单
     * @param processCode
     * @throws Exception
     */
    void processListByPage(String processCode) throws Exception;

    /**
     * 循环处理四个组件审批单
     * @throws Exception
     */
    void loopProcessingApproval() throws Exception;

    /**
     * 获取token
     * @return
     * @throws Exception
     */
    String getAccessToken() throws Exception;

    /**
     * 获取用户待审批实例列表
     * @param token
     * @param userId
     * @param offset
     * @param cnt
     * @param status
     * @return
     * @throws ApiException
     */
    OapiProcessWorkrecordTaskQueryResponse.PageResult getUserApprovalIns(String token, String userId,
                                                                                 long offset, long cnt, long status) throws ApiException;

    /**
     * 获取用户待审批实例ids
     * @return
     * @throws ApiException
     */
    List<String> getApprovalIds() throws ApiException;

    /**
     * 循环处理数据
     * @throws Exception
     */
    void processApprovalIds() throws Exception;

    /**
     * 根据时间范围是否导出过导出待审批数据
     * @param startDate
     * @param endDate
     * @param flag true 全量导出（未审批）  false 导出增量（未审批的）
     * @return
     * @throws IOException
     */
    byte[] exportExpensesToExcel(String startDate, String endDate, Boolean flag) throws IOException;


    /**
     * 根据时间范围导出数据已审批数据
     * @param startDate
     * @param endDate
     * @param flag true 全量导出（已审批+待审批）  false 导（已审批的）
     * @return
     * @throws IOException
     */
    byte[] exportExcelIsComplete(String startDate, String endDate,Boolean flag) throws IOException;

    /**
     * 刷新现有工单状态
     */
    void refreshStatus();
}
